<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ page import="java.util.ArrayList" %>
<%@ page import="hh.g" %>
<jsp:useBean id="myCar" class="hh.s" scope="session"></jsp:useBean>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP '306s.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
 <%
	ArrayList buylist=myCar.getBuylist();
	float total=0;
 %>
 <table border="1" width="450" rules="none" cellspacing="0" cellpadding="0" >
  <tr height="50" >
    <td>购买的商品如下</td>
  </tr>
  <tr align="center" height="30" bgcolor="lightgrey">
    <td width="25%">名称</td>
    <td>价格（元/斤）</td>
    <td>数量</td>
    <td>总价（元）</td>
    <td>移除</td>
  </tr>
  <% if(buylist==null||buylist.size()==0){ %>
  		<tr height="100">
  			<td colspan="5" align="center">你的购物车为空！</td>
  		</tr>
  <%
  	}
  	else{
  		for(int i=0;i<buylist.size();i++){
  		g single=(g)buylist.get(i);
  		String name=single.getName();
  		float price=single.getPrice();
  		int num=single.getNum();
  		float money=((int)((price*num+0.05f)*10))/10f;
  		total+=money;
  %>
  <tr align="center" height="50">
  	<td><%=name %></td>
  	<td><%=price %></td>
  	<td><%=num %></td>
  	<td><%=money %></td>
  	<td>
  		<a href="306d.jsp?action=remove&name=<%=single.getName() %>">移除</a>
  	</td>
  </tr>
  <%
  		}
  		}
   %>
   		<tr height="50" align="center"><td colspan="5">应付金额：<%=total %></td></tr>
   		<tr height="50" align="center">
   				<td colspan="2"><a href="306.jsp">继续购物</a></td>
   				<td colspan="3"><a href="306d.jsp?action=clear">清空购物车</a></td>
   		</tr>
</table>
 
  </body>
</html>
